import React from 'react';
import Taro from '@tarojs/taro';
import {connect} from 'react-redux';
import {View, Button, Image} from '@tarojs/components';
import {AtModal, AtModalContent} from 'taro-ui';
console.log('exchangeDetailModal atmodal', AtModal);

import * as T from '../../types';
import actions from '../../actions/index';
import {store2Props} from '../../selectors';
import {OSS_PATH_PREFIX, OSS_BASE_PATH_PREFIX} from '../../constant';

type IInfoProps = T.IProps & T.IInfoProps;

import './ExchangeDetailModal.less';
import 'taro-ui/dist/style/components/modal.scss';

// @ts-ignore
@connect<Partial<IInfoProps>, T.IInfoState>(store2Props, actions)
/**
 * 兑换说明弹框
 */
export default class ExchangeDetailModal extends React.Component<Partial<IInfoProps>, T.IInfoState> {
  // 使用state值
  constructor(props) {
    super(props);
    this.state = {
      atModal: {
        closeOnClickOverlay: false,
      },
      pics: {
        closeIcon: OSS_PATH_PREFIX + '/exchangeDetailModalClose.png',
      },
    };
  }

  /**
   * 渲染
   * @returns
   */
  render() {
    let {
      visible,
      navbarSettings,
      actions: {action},
    } = this.props;
    const {atModal, pics} = this.state;
    return (
      <AtModal
        isOpened={visible}
        className="exchangeDetailModal"
        closeOnClickOverlay={atModal.closeOnClickOverlay}
        atModalStyle={{top: navbarSettings.navBarHeight}}
      >
        <AtModalContent>
          <View className="modalContent">
            <View className="modalHeader">
              <View className="modalTitle">兑换说明</View>
              <Image src={pics.closeIcon} className="closeIcon" onClick={this.handleCancel} />
            </View>
            <View className="modalExtraContent">
              <View>1. 魔力豆在金币雨游戏中可获得 </View>
              <View>2. 魔力豆可用于兑换 </View>
              <View>3. 一旦兑换不可撤销 </View>
              <View>4. 解释权归江苏瑞银科技有限公司所有 </View>
            </View>
          </View>
        </AtModalContent>
      </AtModal>
    );
  }

  handleCancel = () => {
    this.props.onCancel();
  };
}
